using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class LoadCharacterButton : MonoBehaviour {
	
	public GameObject WindowPrefab;

	// Use this for initialization
	void Start () {
		UIButtonMessage message = gameObject.AddComponent<UIButtonMessage>();
		message.target = gameObject;
		message.functionName = "LoadCharacterMenu";
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void LoadCharacterMenu()
	{
		BrowserManager.CreateCharacterBrowser(gameObject, "CharacterSelected");
	}
	
	void CharacterSelected(List<string> selectedCharacters)
	{
		if(selectedCharacters != null && selectedCharacters.Count > 0 && selectedCharacters[0] != null)
		{
			SheetManager.LoadCharacter(selectedCharacters[0]);
			
			GameObject g = Instantiate(WindowPrefab) as GameObject;
			g.transform.parent = this.transform.parent.parent;
			g.transform.localScale = Vector3.one;
			
			g.transform.localPosition = Vector3.back*2;
		}
	}
}
